<?php
$total       = 6;
$threads     = 3;

$year_start  = 1980;
$year_stop   = 1982;
$year        = $year_start;

$day_start   = 1;
$day_stop    = 3;
$day         = $day_start;

$st          = 0;
$st_max      = 100;
$is_end   = 0;

do {
	for($l = 0; (($l < $total) && ($is_end == 0)); $l += $threads) {
		unset($url);
		for($t = 0; $t < $threads; $t++) {
			if($st < $st_max) {
				$is_add = 1;
			} else {
				$is_end = 1;
				
				
				
				
				break; # выходим из цикла for $t
			}

			$url[$t]  = "day=".$day;
			$url[$t] .= "\tyear=".$year;
			$url[$t] .= "\tst=".$st;

			if($is_add == 1) {
				$is_add = 0;
				$st    += 10;
			} else {

			}
		}

		if($is_end == 1) {
			if($day < $day_stop) {
				$st     = 0;
				$is_end = 0;
				$day++;
			} else {
				if($year < $year_stop) {
					$st     = 0;
					$is_end = 0;
					$day       = $day_start;
					$year++;
				}
			}
			echo "------------------ last thread -------------------\n";
		} else {
			echo "--------------------- thread ---------------------\n";
		}

		if(isset($url)) {
			for($t = 0; $t < count($url); $t++) {
				echo "login=".($l+$t)." \tl=".$l."\tt=".$t."\t".$url[$t]."\n";
			}
				
		}
	}
} while($is_end == 0);

?>